package com.caac.core.config;

import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Expression;
import java.util.Map;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright caac 2006</p>
 * <p>Company: caac</p>
 * @author <a href="mailto:project@caac.com.cn">Project Group</a>
 * @version 1.0
 */

public class StartLikeOperator extends LikeOperator {
    protected MatchMode getMatchMode() {
        return MatchMode.START;
    }
    public Criterion getCriterion(Map propMap, DmProperty dp) {
       Object[] objects = (Object[]) propMap.get(dp.getName());
       if (objects == null) {
           return null;
       }
       return Expression.like(dp.getAlias().getName(),
                              (String) objects[0] + "%");
   }

}
